<?php

/**
 * Comment form base class.
 *
 * @method Comment getObject() Returns the current form's model object
 *
 * @package    IPLIFE
 * @subpackage form
 * @author     alexey.shapran@gmail.com
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseCommentForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'          => new sfWidgetFormInputHidden(),
      'entity_id'   => new sfWidgetFormInputText(),
      'entity_type' => new sfWidgetFormChoice(array('choices' => array('article' => 'article', 'reliz' => 'reliz', 'event' => 'event', 'news' => 'news', 'post' => 'post'))),
      'body'        => new sfWidgetFormTextarea(),
      'user_id'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser'), 'add_empty' => true)),
      'created_at'  => new sfWidgetFormDateTime(),
      'guest_name'  => new sfWidgetFormTextarea(),
    ));

    $this->setValidators(array(
      'id'          => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
      'entity_id'   => new sfValidatorInteger(array('required' => false)),
      'entity_type' => new sfValidatorChoice(array('choices' => array(0 => 'article', 1 => 'reliz', 2 => 'event', 3 => 'news', 4 => 'post'), 'required' => false)),
      'body'        => new sfValidatorString(array('required' => false)),
      'user_id'     => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser'), 'required' => false)),
      'created_at'  => new sfValidatorDateTime(array('required' => false)),
      'guest_name'  => new sfValidatorString(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('comment[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Comment';
  }

}
